/*
 * Copyright 2025 The JA-SIG Collaborative. All rights reserved. distributed with this file and
 * available online at
 */
package com.lap.auth.adapter.driving.persistence.project;

import java.util.List;

import com.lap.auth.adapter.driving.persistence.project.po.ProjectPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import com.lap.auth.domain.project.Project;
import com.lap.auth.domain.project.valueobject.ProjectType;
import com.lap.auth.domain.project.valueobject.StatusType;
import com.lap.framework.tools.EnumUtil;

@Mapper(componentModel = "spring")
public interface ProjectConverter {

  @Mapping(target = "event", ignore = true)
  Project toDomain(ProjectPo projectPo);

  List<Project> toDomains(List<ProjectPo> list);

  ProjectPo toPo(Project project);

  List<ProjectPo> toPoList(List<Project> list);

  default ProjectType codeToType(Integer code) {
    return EnumUtil.fromCode(ProjectType.class, code);
  }

  default Integer typeToCode(ProjectType type) {
    return type.getCode();
  }

  default StatusType codeToStatus(Integer code) {
    return EnumUtil.fromCode(StatusType.class, code);
  }

  default Integer statusToCode(StatusType type) {
    return type.getCode();
  }

}
